package com.lz.controller;

import com.lz.frame.annotation.AnonymousAccess;
import com.lz.frame.common.R;
import com.xinchili.LoggerRecord;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/log")
public class LogController {


    @AnonymousAccess
    @GetMapping("/test")
    public R test(String name) {
        System.out.println(name + "我真凶了");
        return R.success("success");
    }

    @PreAuthorize("hasRole('管理员')")
    @PostMapping("/test222")
    public R test222(@RequestBody LoggerRecord logger) throws InterruptedException {
        Thread.sleep(1000);
        return R.success("success");
    }

    @PreAuthorize("hasRole('打杂的')")
    @PostMapping("/2")
    public R test2222(@RequestBody LoggerRecord logger) throws InterruptedException {
        Thread.sleep(1000);
        return R.success("success");
    }


    @GetMapping("/error")
    public String error() {
        int a = 1 / 0;
        return "R.success(success)";
    }
}
